package tutorial;

import gui.RiskGUI;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import resources.images.ImagesPath;

import com.swtdesigner.SWTResourceManager;

public class StepFive implements TutorialWindow {

	private Text hereYouAreText;
	protected Object result;
	protected Shell shell;
	protected Shell parent;
	private Tutorial tutorial;

	/**
	 * Create the dialog
	 * @param parent
	 * @param tutorial 
	 */
	public StepFive(Shell parent, Tutorial tutorial) {
		this.parent = parent;
		this.tutorial = tutorial;
	}

	/**
	 * Open the dialog
	 */
	public void open() {
		createContents();
		shell.open();
		shell.layout();
	}

	/**
	 * Create contents of the dialog
	 */
	protected void createContents() {
		shell = new Shell(parent, SWT.DIALOG_TRIM);
		shell.addShellListener(new ShellAdapter() {
			public void shellClosed(final ShellEvent e) {
				tutorial.endTutotial();
			}
		});
		shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
		shell.setBackgroundImage(new Image(Display.getDefault(), ImagesPath.getImageStream("tutorial_background.png")));
		shell.setLocation(parent.getBounds().width,0);
		shell.setSize(219, RiskGUI.display.getClientArea().height);
		shell.setText("Step five");

		final Label welcomeToRiskLabel = new Label(shell, SWT.CENTER);
		welcomeToRiskLabel.setBounds(0, 5, 213, 88);
		welcomeToRiskLabel.setForeground(SWTResourceManager.getColor(255, 0, 0));
		welcomeToRiskLabel.setFont(SWTResourceManager.getFont("Comic Sans MS", 22, SWT.NONE));
		welcomeToRiskLabel.setText("Step five: move soldiers");

		hereYouAreText = new Text(shell, SWT.WRAP | SWT.V_SCROLL);
		hereYouAreText.setBackgroundImage(SWTResourceManager.getImage(StepFive.class, "/resources/images/tutorial_background.png"));
		hereYouAreText.setBounds(10, 99, 193, 486);
		hereYouAreText.setText("After you added soldiers, attacked and thought hard on a winning strategy, you are left to pass the turn. To do so, click on the \"Commit\" option under the \"Actions\" menu, use the shortcut CTRL+C, or click the commit button at the bottom right corner of the window.\nAfter the commit, you are asked if you want to move soldiers between your contries. If you want to do so, click yes.\nTo move soldiers, click on the country you want to move soldiers from and afterwards click on the country you want to move soldiers to. The countries you choose have to be connected by a chain of countries you own. For example, Middle East in nieghebour of Afghanistan, which is a neighbour of Ural, so if you were the owner of this countries, you were able to move soldiers between Middle East and Ural although they're not a direct neighbours.\nAftwer a choice has been made, in the openned window choose how many soldiers you want to move and click \"Move\" to send them to their journey.");
		hereYouAreText.setFont(SWTResourceManager.getFont("Comic Sans MS", 11, SWT.BOLD));

		final Label label = new Label(shell, SWT.NONE);
		label.addMouseListener(new MouseAdapter() {
			public void mouseDown(final MouseEvent arg0) {
				tutorial.prvStep();
			}
		});
		label.setToolTipText("Attack");
		label.setBackgroundImage(new Image(Display.getCurrent(), ImagesPath.getImageStream("left.gif")));
		label.setBounds(90, shell.getBounds().height-100, 58, 58);
		
		final Label label_1 = new Label(shell, SWT.NONE);
		label_1.addMouseListener(new MouseAdapter() {
			public void mouseDown(final MouseEvent arg0) {
				tutorial.nextStep();
			}
		});
		label_1.setToolTipText("Finish");
		label_1.setBackgroundImage(new Image(Display.getCurrent(), ImagesPath.getImageStream("right.gif")));
		label_1.setBounds(150, shell.getBounds().height-100, 58, 58);
		//
	}

	public Shell getShell() {
		return shell;
	}

}
